package com.iknight.finance.controller;

import com.github.pagehelper.PageInfo;
import com.iknight.finance.entity.InvestInfoEntity;
import com.iknight.finance.service.InvestInfoService;
import com.iknight.mgr.core.base.BaseController;
import com.iknight.mgr.core.constant.IkgConstantCode;
import com.iknight.mgr.core.utils.IkgWebUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.Serializable;
import java.util.Map;

@RestController
@RequestMapping(value = "/rest/fico/investinfo")
public class InvestInfoController implements BaseController {
    @Autowired
    private InvestInfoService<InvestInfoEntity> investInfoService;

    @Override
    @PostMapping("/save")
    public Object save(@RequestBody Map params, HttpServletRequest request, HttpServletResponse response) {
        return null;
    }

    @Override
    @PostMapping("/delete")
    public Object delete(@RequestBody Map params, HttpServletRequest request, HttpServletResponse response) {
        return null;
    }

    @Override
    @PostMapping("/selectOne")
    public Object selectOne(@RequestBody Map params, HttpServletRequest request, HttpServletResponse response) {
        return null;
    }

    @Override
    @PostMapping("/selectByPage")
    public Object selectByPage(@RequestBody Map params, HttpServletRequest request, HttpServletResponse response) {
        if (params == null) {
            return IkgWebUtils.postIkgResponse(false, "传入参数为空", IkgConstantCode.PARAMSNULL);
        }
        PageInfo<InvestInfoEntity> records = investInfoService.selectByPage(params);
        return IkgWebUtils.postResult(records.getTotal(), records.getList());

    }

    @Override
    public Serializable format(Map params) {
        return null;
    }

    @Override
    public boolean isPKeyNotNull(Map params) {
        return false;
    }
}
